package com.googlecode.imanager.core.base;

import com.googlecode.imanager.client.Document;
import com.googlecode.imanager.client.Manager;
import com.googlecode.imanager.client.io.Path;
import com.googlecode.imanager.client.media.Image;

/**
 * @author wellsantos@wellsantos.com
 * @since 0.01
 */
public class DefaultImage extends Image {

    private static final long serialVersionUID = 1L;
    
    private transient Object cachedContent;
    private transient Path cachedPath;

    public DefaultImage(Document owner, Path path) {
        super(owner, path);
    }

    @Override
    public void loadContent() {
        BridgeControl control = (BridgeControl) Manager.lookupImpl(getOwner());
        control.getBridgeApplication().loadImageContent(this);
    }

    public Object getCachedContent() {
        return cachedContent;
    }

    public void setCachedContent(Object cachedContent) {
        this.cachedContent = cachedContent;
    }

    public void setPathChanged(boolean value){
        if (value){
            cachedPath = null;
        } else {
            cachedPath = getPath();
        }
    }

    public boolean isPathChanged(){
        return !getPath().equals(cachedPath);
    }
    
}
